# -*- coding: utf-8 -*-
#
# Copyright (c) 2011,2012 RMIT e-Research Office
#   (RMIT University, Australia)
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#    *  Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#    *  Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#    *  Neither the name of RMIT University nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

# Django settings for the SMRA project deployed under runserver

from os import path

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

SUB_SITE = "smra"

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': path.join(path.dirname(__file__),'db/django.sql').replace('\\','/'),                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = None

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

STATIC_DOC_ROOT = path.join(path.dirname(__file__),
                               'smra_portal/site_media').replace('\\', '/')

#STATIC_URL = path.join(path.dirname(__file__),'smra_portal/site_media').replace('\\','/')
#STATIC_URL = path.join('/site_media/').replace('\\','/')

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/site_media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'lpw@bqiq#lwcx0w=xo=j@z9#h!d&8svwz5fwv0_j1319^%92p_'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.transaction.TransactionMiddleware',
    'smra.middleware.http.Http403Middleware'
)

ROOT_URLCONF = 'smra.urls'

TEMPLATE_DIRS = (
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    path.join(path.dirname(__file__),
    'smra_portal/templates/').replace('\\','/'),
    path.join(path.dirname(__file__),
    'smra_portal/publish/').replace('\\','/')
)

TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",
     "django.core.context_processors.debug",
     "django.core.context_processors.i18n",
     "django.contrib.messages.context_processors.messages")

OUR_APPS = ('smra.smra_portal',)

INSTALLED_APPS = (
    'django_extensions',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'django.contrib.markup',
    'django_nose',
    'south'
) + OUR_APPS



LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },

    'handlers': {
        'console':{
            'level':'DEBUG',
            'class':'logging.StreamHandler',
            'formatter': 'simple'
        },
        'file': {
            'level':'DEBUG',
            'class': 'logging.FileHandler',
            'filename': './smra.log',
            'formatter': 'simple'
        },
    },
    
    'loggers': {
        'smra': {
            'handlers': ['file'],
            'level': 'INFO',
            },
    },
}     
    

FIXTURE_DIRS = (
                path.join(path.dirname(__file__),
                               'smra_portal/site_media').replace('\\', '/'),)
    

AUTH_PROFILE_MODULE = "smra_portal.UserProfile"
    
    
# The ingestion plugins that will be run for SMRA        
REPOS = [
    "smra.smra_portal.repos.Bonza2.ReposConverter",
    "smra.smra_portal.repos.Mayer.ReposConverter",
    "smra.smra_portal.repos.Afirc.ReposConverter"]   

# Bonza plugin settings
BONZAHOST = '127.0.0.1'
BONZAPORT = 3306
BONZAUSER = 'smra'
BONZAPASS = 'CHANGEME'
BONZADB = 'bonza'

# Webservice access settings.
PROXY=None
#PROXY= {'http': 'http://USERNAME:PASSWORD@PROXYHOST:PROXYPORT'}

# Mayer plugin settings
MAYERWSDL = ""
MAYER_FIELDS_TO_SKIP = ['TITLE']
MAYER_CALL_ATTEMPTS = 3
MAYER_LINK = "http://afidb.adc.rmit.edu.au/dbtw-wpd/exec/dbtwpub.dll?AC=QBE_QUERY&TN=Mayer&RF=Full+record&NP=4&QY=ID+=+%s" 

# AFI plugin settings
AFIWSDL = ""
SERVICE_CALL_TIMEOUT = 60*60*60
AFI_CALL_ATTEMPTS = 5
MAXIMUM_AFI_ID =57800
START_AFI_ID = 1
AFI_CALL_STEP = 200
AFI_LINK = "http://afidb.adc.rmit.edu.au/dbtw-wpd/exec/dbtwpub.dll?AC=QBE_QUERY&TN=Catalog&RF=Full+record&NP=4&QY=ID+=+%s"
        

# The default schema of meta data for a virtual collection
VIRT_META_SCHEMA_NAMESPACE="http://smra.rmit.edu.au/"
VIRT_META_SCHEMA_NAME="basic-virtual-collection"
RIFCS_PARTY_SCHEMA = "http://rmit.edu.au/rif-cs/party/1.0/"  
PUBLISH_PROVIDERS = ('smra.smra_portal.publish.rif_cs_profile.rif_cs_PublishProvider.rif_cs_PublishProvider',)  
                     
# The set of schemas that will appear in search pages                                        
SEARCH_SCHEMAS=(
    ('http://smra.edu.au/smra','film'),
    ('http://smra.edu.au/smra','book'),
    ('http://rmit.edu.au/schemas/smra','base'),
    ('http://rmit.edu.au/schemas/smra','extended'))

DEFAULT_RESULTS_PER_PAGE = 20
NUM_PREVIOUS_SEARCHES = 10
# For pagination in the search results page
RESULTS_PER_PAGE = 25
                  
# ANDS Services
KEY_HANDLE_ENABLE = False                  
AUTHTYPE = "URL"
IDENTIFIER = "bob"
AUTHDOMAIN = "www.rmit.edu.au"
APPID = "7ffab897986da93b8467d9fcf83e6a1a598cba398a4ff64e6b1" #this is fake
MINTURL = "http://127.0.0.1:8000/smra/mint"

# This switches on an alternative query string for media objects.  
# However, these alternative may have different performance on different 
# backend choices, so we will need to test which is better when we have more data.
# This will disappear in time.
ORIG_QUERY= True

